/*
 * Tests.cpp
 *
 *  Created on: Oct 18, 2012
 *      Author: David Kadlecek, Ales Fiser
 */

#include "Tests.h"
#include "Task.h"

Tests::Tests() {
}

Tests::~Tests() {
}

void Tests::runTests() {
	int sizeOfProblem = 5;
	Task* task = new Task();
	task->createFullTask(sizeOfProblem);
	if (task->getActualState()[0] != 0) {
		cout << "TaskTest problem, at index 0 should be 0 but is " << task->getActualState()[0];
	}
	for (int i = 1; i < sizeOfProblem; ++i) {
		if (task->getActualState()[i] != EMPTY) {
			cout << "TaskTest problem, at index " << i << " should be -1 but is " << task->getActualState()[i];
		}
	}

	task->nexByInreaseDepth();
	if (1 != task->getActualState()[1]) cout << "TaskTest problem, after increase should be 1, but is  " << task->getActualState()[1] << endl;
	task->nexByInreaseDepth();
	if (2 != task->getActualState()[2]) cout << "TaskTest problem, after increase should be 2, but is  " << task->getActualState()[2] << endl;
	task->nexByInreaseDepth();
	if (3 != task->getActualState()[3]) cout << "TaskTest problem, after increase should be 3, but is  " << task->getActualState()[3] << endl;
	task->nextByWidth();
	if (4 != task->getActualState()[3]) cout << "TaskTest problem, after go width should be 4, but is  " << task->getActualState()[3] << endl;
	task->nextByWidth();
	if (5 != task->getActualState()[3]) cout << "TaskTest problem, after go width should be 5, but is  " << task->getActualState()[3] << endl;
	task->nextByWidth();
	if (5 != task->getActualState()[3]) cout << "TaskTest problem, after go width should be 5, but is  " << task->getActualState()[3] << endl;
	task->decreaseDepth();
	if (3 != task->getActualState()[2]) cout << "TaskTest problem, decrease width should be 2, but is  " << task->getActualState()[2] << endl;
	task->nextByWidth();
	if (1 != task->getActualState()[2]) cout << "TaskTest problem, after go width should be 3, but is  " << task->getActualState()[2] << endl;

	delete task;
	//	doTestPossibleQ();

}

//test na testdata 2
void Tests::doTestPossibleQ() {

	InputMatrixHolder* matrix = new InputMatrixHolder();
	matrix->readFromFile("testdata/test2");
	SequentialCore* seqCore = new SequentialCore();
	seqCore->loadInputMatrix(matrix);

	int* testAr = new int[matrix->getNumberOfNodes()];

	testAr[0] = 1;
	testAr[1] = 4;
	testAr[2] = 2;
	testAr[3] = -1;
	testAr[4] = -1;

	if (seqCore->isPossibleClique(testAr, 2) == 0) {
		cout << "nevysel test 1 " << endl;
	}

	testAr[0] = 0;
	testAr[1] = 3;
	testAr[2] = -1;
	testAr[3] = -1;
	testAr[4] = -1;

	if (seqCore->isPossibleClique(testAr, 1) == 0) {
		cout << "nevysel test 2" << endl;
	}

	testAr[0] = 1;
	testAr[1] = 3;
	testAr[2] = 2;
	testAr[3] = -1;
	testAr[4] = -1;

	if (seqCore->isPossibleClique(testAr, 2) == 1) {
		cout << "nevysel test 3" << endl;
	}

	delete testAr;
	delete seqCore;
}
